package PatternOfDesign.Singleton;

/**
 * Created by Ghost on 2015/3/4 0004.
 */
public class AbstractFactory {
    public static void main(String[] args){
        Factory dogFac = new DogFactory();
        Animal dog = dogFac.getAnimal();
        Factory catFac = new CatFactory();
        Animal cat = catFac.getAnimal();

    }
}

interface Animal{
    public void eat();
    public void shout();
    public void run();
    public void sleep();
}

interface Factory{
    public Animal getAnimal();
}

class Dog implements Animal{

    @Override
    public void eat() {
        System.out.println("dog eat");
    }

    @Override
    public void shout() {
        System.out.println("dog shout");

    }

    @Override
    public void run() {
        System.out.println("dog run");

    }

    @Override
    public void sleep() {
        System.out.println("dog sleep");

    }
}

class Cat implements Animal{

    @Override
    public void eat() {
        System.out.println("cat eat");

    }

    @Override
    public void shout() {
        System.out.println("cat shout");

    }

    @Override
    public void run() {
        System.out.println("cat run");

    }

    @Override
    public void sleep() {
        System.out.println("cat sleep");

    }
}

class DogFactory implements Factory{

    @Override
    public Animal getAnimal() {
        return new Dog();
    }
}

class CatFactory implements Factory{

    @Override
    public Animal getAnimal() {
        return new Cat();
    }
}

